<template>
  <view class="wrap">
    <u--text
      text="用户的建议是最宝贵的财富。"
      size="46rpx"
      lineHeight="48rpx"
      color="#888888"
    ></u--text>
    <u--text
      text="您可以留下联系方式，一旦采纳您的建议，我们可以联系您并快递一份健康礼品。"
      size="46rpx"
      lineHeight="58rpx"
      margin="20rpx 0 0"
      color="#888888"
    ></u--text>
	<u-text
	text="【商务合作】请留下您的联系方式。您也可以发送邮件至59679490@QQ.com"
	size="34rpx"
	lineHeight="46"
	margin="20rpx 0 0"
	color="#888888"></u-text>
    <view class="l-mt-10">
      <textarea
        count
        :maxlength="2000"
        v-model="form.feedback"
        placeholder="请输入内容"
        style="
          width: 100%;
          height: 300rpx;
          font-size: 46rpx;
          border: 1px solid #e5e5e5;
          border-radius: 10rpx;
          padding: 20rpx;
        "
        placeholder-style="fontSize:46rpx;color: #e5e5e5"
      ></textarea>
    </view>
    <view class="btn-large" @click="submit">发送</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      form: {
        feedback: "",
      },
    };
  },
  methods: {
    async submit() {
      if (!this.form.feedback) {
        this.$toast("请输入您的反馈");
        return;
      }
      try {
        await this.$ajax.user.addAdvice({
          openid: uni.getStorageSync("openid"),
          content: this.form.feedback,
        });
        this.$toast("感谢您的反馈");
        setTimeout(() => {
          this.$back();
        }, 1000);
      } catch (error) {
        console.log(error);
        if (error && String(error.errCode) === "1002") {
          this.$toast("今日反馈次数已达上限");
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.wrap {
  padding: 20rpx;
  .tit-1 {
    font-size: $uni-font-size-base;
    font-weight: bold;
  }
  .btn-large {
    margin: 30rpx auto 0;
    width: 100%;
  }
}
</style>
